<?php
/**
 * @ClassName: Marketing
 * @Description: TODO
 * @author: gydtrade
 * @Date: 2025-10-16 17:06
 * @Version: V1.0.0
 */

namespace app\api\controller\merchant;

use app\api\controller\Api;
use app\common\model;

class Marketing extends Api
{
    protected $noNeedLogin = ['getActivityList', 'detail'];

    /**
     * 营销活动列表
     * @return \think\response\Json
     */
    function getActivityList()
    {
        $skip = input('skip', 0);
        $limit = input('limit', 10);

        $where = [];
        $where[] = ['status', '=', 1];//审核状态：0待审，1通过，2驳回
        $where[] = ['pay_status', '=', 1];//支付状态：0待支付，1已支付
        $where[] = ['done', '=', 1];//活动状态：0未开始，1进行中，2已结束

        $list = model\Marketing::where($where)->order('create_time desc')->limit($skip, $limit)->select();

        foreach ($list as &$item) {
            $item['store'] = model\Store::get($item['store_id']);
        }

        $result = [
            'list' => $list,
            'is_more' => count($list) >= $limit
        ];

        return json(['code' => 1, 'msg' => '获取成功', 'data' => $result]);
    }

    /**
     * 营销活动详情
     * @return \think\response\Json
     */
    function detail()
    {
        $id = input('id', 0);

        $data = model\Marketing::get($id);

        if ($data) {

        }

        return json(['code' => 1, 'data' => $data]);
    }

}